﻿#include "LibraryEditor.LMain.h"
#include "Program.h"
#include "Graphics/MLibraryV0.h"

using namespace Shared::Extensions;

namespace LibraryEditor
{

    LMain::LMain()
    {
        InitializeComponent();

//C# TO C++ CONVERTER TODO TASK: There is no C++ equivalent to the C# 'typeof' operator:
        this->FrameAction->ValueType = typeof(MirAction);
//C# TO C++ CONVERTER TODO TASK: There is no C++ equivalent to the C# 'typeof' operator:
        this->FrameAction->DataSource = Enum::GetValues(typeof(MirAction));


        SendMessage(PreviewListView->Handle, 4149, 0, 5242946); //80 x 66

        this->AllowDrop = true;
        this->DragEnter += new DragEventHandler(Form1_DragEnter);
        this->DragDrop += new DragEventHandler(Form1_DragDrop);

        if (Program::getOpenFileWith().length() > 0 && FileSystem::fileExists(Program::getOpenFileWith()))
        {
            OpenLibrary(Program::getOpenFileWith());
        }
    }

    void LMain::Form1_DragDrop(std::any sender, DragEventArgs *e)
    {
        std::vector<std::string> files = static_cast<std::vector<std::string>>(e->Data->GetData(DataFormats::FileDrop));

        if (StringHelper::toUpper(Path::GetExtension(files[0])) == ".WIL" || StringHelper::toUpper(Path::GetExtension(files[0])) == ".WZL" || StringHelper::toUpper(Path::GetExtension(files[0])) == ".MIZ")
        {
            toolStripProgressBar->Maximum = files.size();
            toolStripProgressBar->Value = 0;

            std::function<void()> tempVar([&] ()
            {
                try
                {
                    ParallelOptions *options = new ParallelOptions();
                    options->MaxDegreeOfParallelism = 8;
                    Parallel::For(0, files.size(), options, [&] (std::any i)
                    {
                            if (Path::GetExtension(files[i]) == ".wtl")
                            {
                                WTLLibrary *WTLlib = new WTLLibrary(files[i]);
                                WTLlib->ToMLibrary();

                delete WTLlib;
                            }
                            else
                            {
                                WeMadeLibrary *WILlib = new WeMadeLibrary(files[i]);
                                WILlib->ToMLibrary();

                delete WILlib;
                            }

                            std::function<void()> tempVar2([&] ()
                            {
                                toolStripProgressBar->Value++;
                            });
                            Invoke(&tempVar2);

                    });

//C# TO C++ CONVERTER TODO TASK: A 'delete options' statement was not added since options was passed to a method or constructor. Handle memory management manually.
                }
                catch (const std::runtime_error &ex)
                {
                    MessageBox::Show(ex.what());
                }
    
                std::function<void()> tempVar3([&] ()
                {
                        toolStripProgressBar->Value = 0;
                });
                Invoke(&tempVar3);
    
                MessageBox::Show(StringHelper::formatSimple("Successfully converted {0} {1}", std::to_string(files.size()), (files.size() > 1) ? "libraries" : "library"));
            });
            (&tempVar)->BeginInvoke(nullptr, std::any());
        }
        else if (StringHelper::toUpper(Path::GetExtension(files[0])) == ".LIB")
        {
            ClearInterface();
            ImageList->Images->Clear();
            PreviewListView->Items->Clear();
            _indexList.clear();

            if (_library != nullptr)
            {
                _library->Close();
            }
            _library = new MLibraryV2(files[0]);
            PreviewListView->VirtualListSize = _library->Images.size();
            PreviewListView->RedrawItems(0, PreviewListView->Items->Count - 1, true);

            // Show .Lib path in application title.
//C# TO C++ CONVERTER TODO TASK: There is no C++ equivalent to 'ToString':
            this->Text = files[0].ToString();
        }
        else
        {
            return;
        }
    }

    void LMain::Form1_DragEnter(std::any sender, DragEventArgs *e)
    {
        if (e->Data->GetDataPresent(DataFormats::FileDrop))
        {
            e->Effect = DragDropEffects::Copy;
        }
    }

    void LMain::ClearInterface()
    {
        _selectedImage = nullptr;
        ImageBox->Image = nullptr;
        ZoomTrackBar->Value = 1;

        WidthLabel->Text = "<No Image>";
        HeightLabel->Text = "<No Image>";
        OffSetXTextBox->Text = "";
        OffSetYTextBox->Text = "";
        OffSetXTextBox->BackColor = SystemColors::Window;
        OffSetYTextBox->BackColor = SystemColors::Window;
    }

    void LMain::PreviewListView_SelectedIndexChanged(std::any sender, EventArgs *e)
    {
        if (PreviewListView->SelectedIndices->Count == 0)
        {
            ClearInterface();
            return;
        }

        _selectedImage = _library->GetMImage(PreviewListView->SelectedIndices[0]);

        if (_selectedImage == nullptr)
        {
            ClearInterface();
            return;
        }

        WidthLabel->Text = std::to_string(_selectedImage->Width);
        HeightLabel->Text = std::to_string(_selectedImage->Height);

        OffSetXTextBox->Text = std::to_string(_selectedImage->X);
        OffSetYTextBox->Text = std::to_string(_selectedImage->Y);

        ImageBox->Image = _selectedImage->Image;

        // Keep track of what image/s are selected.
        if (PreviewListView->SelectedIndices->Count > 1)
        {
            toolStripStatusLabel->ForeColor = Color::Red;
            toolStripStatusLabel->Text = "Multiple images selected.";
        }
        else
        {
            toolStripStatusLabel->ForeColor = SystemColors::ControlText;
//C# TO C++ CONVERTER TODO TASK: There is no C++ equivalent to 'ToString':
            toolStripStatusLabel->Text = "Selected Image: " + StringHelper::formatSimple("{0} / {1}", PreviewListView->SelectedIndices[0].ToString(), std::to_string(PreviewListView->Items->Count - 1));
        }

        nudJump->Value = PreviewListView->SelectedIndices[0];
    }

    void LMain::PreviewListView_RetrieveVirtualItem(std::any sender, RetrieveVirtualItemEventArgs *e)
    {
        int index;

        std::unordered_map<int, int>::const_iterator _indexList_iterator = _indexList.find(e.ItemIndex);
        if (_indexList_iterator != _indexList.end())
        {
            index = _indexList_iterator->second;
            e->Item = new ListViewItem();
            e->Item->ImageIndex = index;
//C# TO C++ CONVERTER TODO TASK: There is no C++ equivalent to 'ToString':
            e->Item->Text = e->ItemIndex.ToString();
            return;
        }
        else
        {
            index = _indexList_iterator->second;
        }

        _indexList.emplace(e->ItemIndex, ImageList->Images->Count);
        ImageList->Images->Add(_library->GetPreview(e->ItemIndex));
        e->Item = new ListViewItem();
        e->Item->ImageIndex = index;
//C# TO C++ CONVERTER TODO TASK: There is no C++ equivalent to 'ToString':
        e->Item->Text = e->ItemIndex.ToString();
    }

    void LMain::AddButton_Click(std::any sender, EventArgs *e)
    {
        if (_library == nullptr)
        {
            return;
        }
        if (_library->FileName == "")
        {
            return;
        }

        if (ImportImageDialog->ShowDialog() != System::Windows::Forms::DialogResult::OK)
        {
            return;
        }

        std::vector<std::string> fileNames(ImportImageDialog->FileNames);

        //fileNames.Sort();
        toolStripProgressBar->Value = 0;
        toolStripProgressBar->Maximum = fileNames.size();

        for (int i = 0; i < fileNames.size(); i++)
        {
            std::string fileName = fileNames[i];
            Bitmap *image;

            try
            {
                image = new Bitmap(fileName);
            }
            catch (...)
            {
                delete image;
                continue;
            }

            fileName = FileSystem::combine(FileSystem::getDirectoryName(fileName), "Placements", Path::GetFileNameWithoutExtension(fileName));
            fileName = Path::ChangeExtension(fileName, ".txt");

            short x = 0;
            short y = 0;

            if (FileSystem::fileExists(fileName))
            {
                std::vector<std::string> placements = File::ReadAllLines(fileName);

                if (placements.size() > 0)
                {
                    short::TryParse(placements[0], x);
                }
                if (placements.size() > 1)
                {
                    short::TryParse(placements[1], y);
                }
            }

            _library->AddImage(image, x, y);
            toolStripProgressBar->Value++;
            //image.Dispose();

//C# TO C++ CONVERTER TODO TASK: A 'delete image' statement was not added since image was passed to a method or constructor. Handle memory management manually.
        }

        PreviewListView->VirtualListSize = _library->Images.size();
        toolStripProgressBar->Value = 0;
    }

    void LMain::newToolStripMenuItem_Click(std::any sender, EventArgs *e)
    {
        if (SaveLibraryDialog->ShowDialog() != System::Windows::Forms::DialogResult::OK)
        {
            return;
        }

        if (_library != nullptr)
        {
            _library->Close();
        }
        _library = new MLibraryV2(SaveLibraryDialog->FileName);
        PreviewListView->VirtualListSize = 0;
        _library->Save();

        UpdateFrameGridView();
    }

    void LMain::openToolStripMenuItem_Click(std::any sender, EventArgs *e)
    {
        if (OpenLibraryDialog->ShowDialog() != System::Windows::Forms::DialogResult::OK)
        {
            return;
        }

        OpenLibrary(OpenLibraryDialog->FileName);
    }

    void LMain::OpenLibrary(const std::string &filename)
    {
        ClearInterface();
        ImageList->Images->Clear();
        PreviewListView->Items->Clear();
        _indexList.clear();

        if (_library != nullptr)
        {
            _library->Close();
        }
        _library = new MLibraryV2(filename);
        PreviewListView->VirtualListSize = _library->Images.size();

        // Show .Lib path in application title.
        this->Text = filename;

        PreviewListView->SelectedIndices->Clear();

        if (PreviewListView->Items->Count > 0)
        {
            PreviewListView->Items[0]->Selected = true;
        }

        UpdateFrameGridView();
    }

    void LMain::saveToolStripMenuItem_Click(std::any sender, EventArgs *e)
    {
        if (_library == nullptr)
        {
            return;
        }

        UpdateFrameGridData();

        _library->Save();
    }

    void LMain::saveAsToolStripMenuItem_Click(std::any sender, EventArgs *e)
    {
        if (_library == nullptr)
        {
            return;
        }
        if (SaveLibraryDialog->ShowDialog() != System::Windows::Forms::DialogResult::OK)
        {
            return;
        }

        UpdateFrameGridData();

        _library->FileName = SaveLibraryDialog->FileName;
        _library->Save();
    }

    void LMain::closeToolStripMenuItem_Click(std::any sender, EventArgs *e)
    {
        this->Close();
    }

    void LMain::DeleteButton_Click(std::any sender, EventArgs *e)
    {
        if (_library == nullptr)
        {
            return;
        }
        if (_library->FileName == "")
        {
            return;
        }
        if (PreviewListView->SelectedIndices->Count == 0)
        {
            return;
        }

        if (MessageBox::Show("Are you sure you want to delete the selected Image?", "Delete Selected.", MessageBoxButtons::YesNoCancel) != System::Windows::Forms::DialogResult::Yes)
        {
            return;
        }

        std::vector<int> removeList;

        for (int i = 0; i < PreviewListView->SelectedIndices->Count; i++)
        {
            removeList.push_back(PreviewListView->SelectedIndices[i]);
        }

        std::sort(removeList.begin(), removeList.end());

        for (int i = removeList.size() - 1; i >= 0; i--)
        {
            _library->RemoveImage(removeList[i]);
        }

        ImageList->Images->Clear();
        _indexList.clear();
        PreviewListView->VirtualListSize -= removeList.size();
    }

    void LMain::convertToolStripMenuItem_Click(std::any sender, EventArgs *e)
    {
        if (OpenWeMadeDialog->ShowDialog() != System::Windows::Forms::DialogResult::OK)
        {
            return;
        }

        toolStripProgressBar->Maximum = OpenWeMadeDialog->FileNames->Length;
        toolStripProgressBar->Value = 0;

        try
        {
            ParallelOptions *options = new ParallelOptions();
            options->MaxDegreeOfParallelism = 8;
            Parallel::For(0, OpenWeMadeDialog->FileNames->Length, options, [&] (std::any i)
            {
                            if (Path::GetExtension(OpenWeMadeDialog->FileNames[i]) == ".wtl")
                            {
                                WTLLibrary *WTLlib = new WTLLibrary(OpenWeMadeDialog->FileNames[i]);
                                WTLlib->ToMLibrary();

                delete WTLlib;
                            }
                            else if (Path::GetExtension(OpenWeMadeDialog->FileNames[i]) == ".Lib")
                            {
                                MLibraryV1 *v1Lib = new MLibraryV1(OpenWeMadeDialog->FileNames[i]);
                                v1Lib->ToMLibrary();

                delete v1Lib;
                            }
                            else
                            {
                                WeMadeLibrary *WILlib = new WeMadeLibrary(OpenWeMadeDialog->FileNames[i]);
                                WILlib->ToMLibrary();

                delete WILlib;
                            }
                            toolStripProgressBar->Value++;
            });

//C# TO C++ CONVERTER TODO TASK: A 'delete options' statement was not added since options was passed to a method or constructor. Handle memory management manually.
        }
        catch (const std::runtime_error &ex)
        {
            MessageBox::Show(ex.what());
        }

        toolStripProgressBar->Value = 0;

        MessageBox::Show(StringHelper::formatSimple("Successfully converted {0} {1}", std::to_string(OpenWeMadeDialog->FileNames->Length), (OpenWeMadeDialog->FileNames->Length > 1) ? "libraries" : "library"));
    }

    void LMain::copyToToolStripMenuItem_Click(std::any sender, EventArgs *e)
    {
        if (PreviewListView->SelectedIndices->Count == 0)
        {
            return;
        }
        if (SaveLibraryDialog->ShowDialog() != System::Windows::Forms::DialogResult::OK)
        {
            return;
        }

        MLibraryV2 *tempLibrary = new MLibraryV2(SaveLibraryDialog->FileName);

        std::vector<int> copyList;

        for (int i = 0; i < PreviewListView->SelectedIndices->Count; i++)
        {
            copyList.push_back(PreviewListView->SelectedIndices[i]);
        }

        std::sort(copyList.begin(), copyList.end());

        for (int i = 0; i < copyList.size(); i++)
        {
            MLibraryV2::MImage *image = _library->GetMImage(copyList[i]);
            tempLibrary->AddImage(image->Image, image->MaskImage, image->X, image->Y);
        }

        tempLibrary->Save();

        delete tempLibrary;
    }

    void LMain::removeBlanksToolStripMenuItem_Click(std::any sender, EventArgs *e)
    {
        if (MessageBox::Show("Are you sure you want to remove the blank images?", "Remove Blanks", MessageBoxButtons::YesNo) != System::Windows::Forms::DialogResult::Yes)
        {
            return;
        }

        _library->RemoveBlanks();
        ImageList->Images->Clear();
        _indexList.clear();
        PreviewListView->VirtualListSize = _library->Count;
    }

    void LMain::countBlanksToolStripMenuItem_Click(std::any sender, EventArgs *e)
    {
        OpenLibraryDialog->Multiselect = true;

        if (OpenLibraryDialog->ShowDialog() != System::Windows::Forms::DialogResult::OK)
        {
            OpenLibraryDialog->Multiselect = false;
            return;
        }

        OpenLibraryDialog->Multiselect = false;

        MLibraryV2::Load = false;

        int count = 0;

        for (int i = 0; i < OpenLibraryDialog->FileNames->Length; i++)
        {
            MLibraryV2 *library = new MLibraryV2(OpenLibraryDialog->FileNames[i]);

            for (int x = 0; x < library->Count; x++)
            {
                if (library->Images[x]->Length <= 8)
                {
                    count++;
                }
            }

            library->Close();

            delete library;
        }

        MLibraryV2::Load = true;
        MessageBox::Show(std::to_string(count));
    }

    void LMain::OffSetXTextBox_TextChanged(std::any sender, EventArgs *e)
    {
        TextBox *control = dynamic_cast<TextBox*>(sender);

        if (control == nullptr || !control->Focused)
        {
            return;
        }

        short temp;

        if (!short::TryParse(control->Text, temp))
        {
            control->BackColor = Color::Red;
            return;
        }

        control->BackColor = SystemColors::Window;

        for (int i = 0; i < PreviewListView->SelectedIndices->Count; i++)
        {
            MLibraryV2::MImage *image = _library->GetMImage(PreviewListView->SelectedIndices[i]);
            image->X = temp;
        }
    }

    void LMain::OffSetYTextBox_TextChanged(std::any sender, EventArgs *e)
    {
        TextBox *control = dynamic_cast<TextBox*>(sender);

        if (control == nullptr || !control->Focused)
        {
            return;
        }

        short temp;

        if (!short::TryParse(control->Text, temp))
        {
            control->BackColor = Color::Red;
            return;
        }

        control->BackColor = SystemColors::Window;

        for (int i = 0; i < PreviewListView->SelectedIndices->Count; i++)
        {
            MLibraryV2::MImage *image = _library->GetMImage(PreviewListView->SelectedIndices[i]);
            image->Y = temp;
        }
    }

    void LMain::InsertImageButton_Click(std::any sender, EventArgs *e)
    {
        if (_library == nullptr)
        {
            return;
        }
        if (_library->FileName == "")
        {
            return;
        }
        if (PreviewListView->SelectedIndices->Count == 0)
        {
            return;
        }
        if (ImportImageDialog->ShowDialog() != System::Windows::Forms::DialogResult::OK)
        {
            return;
        }

        std::vector<std::string> fileNames(ImportImageDialog->FileNames);

        //fileNames.Sort();

        int index = PreviewListView->SelectedIndices[0];

        toolStripProgressBar->Value = 0;
        toolStripProgressBar->Maximum = fileNames.size();

        for (int i = fileNames.size() - 1; i >= 0; i--)
        {
            std::string fileName = fileNames[i];

            Bitmap *image;

            try
            {
                image = new Bitmap(fileName);
            }
            catch (...)
            {
                delete image;
                continue;
            }

            fileName = FileSystem::combine(FileSystem::getDirectoryName(fileName), "Placements", Path::GetFileNameWithoutExtension(fileName));
            fileName = Path::ChangeExtension(fileName, ".txt");

            short x = 0;
            short y = 0;

            if (FileSystem::fileExists(fileName))
            {
                std::vector<std::string> placements = File::ReadAllLines(fileName);

                if (placements.size() > 0)
                {
                    short::TryParse(placements[0], x);
                }
                if (placements.size() > 1)
                {
                    short::TryParse(placements[1], y);
                }
            }

            _library->InsertImage(index, image, x, y);

            toolStripProgressBar->Value++;

//C# TO C++ CONVERTER TODO TASK: A 'delete image' statement was not added since image was passed to a method or constructor. Handle memory management manually.
        }

        ImageList->Images->Clear();
        _indexList.clear();
        PreviewListView->VirtualListSize = _library->Images.size();
        toolStripProgressBar->Value = 0;
        _library->Save();
    }

    void LMain::safeToolStripMenuItem_Click(std::any sender, EventArgs *e)
    {
        if (MessageBox::Show("Are you sure you want to remove the blank images?", "Remove Blanks", MessageBoxButtons::YesNo) != System::Windows::Forms::DialogResult::Yes)
        {
            return;
        }

        _library->RemoveBlanks(true);
        ImageList->Images->Clear();
        _indexList.clear();
        PreviewListView->VirtualListSize = _library->Count;
    }

    void LMain::ProcessDir(const std::string &sourceDir, int recursionLvl, const std::string &outputDir)
    {
        if (recursionLvl <= HowDeepToScan)
        {
            // Process the list of files found in the directory.
            std::vector<std::string> fileEntries = Directory::GetFiles(sourceDir);
            for (auto fileName : fileEntries)
            {
                if (FileSystem::directoryExists(outputDir) != true)
                {
                    FileSystem::createDirectory(outputDir);
                }
                MLibraryV0 *OldLibrary = new MLibraryV0(fileName);
                MLibraryV2 *NewLibrary = new MLibraryV2(outputDir + FileSystem::getFileName(fileName));
                NewLibrary->Images = std::vector<MLibraryV2::MImage*>();
                NewLibrary->IndexList = std::vector<int>();
                NewLibrary->Count = OldLibrary->Images.size();
                ;
                for (int i = 0; i < OldLibrary->Images.size(); i++)
                {
                    NewLibrary->Images.push_back(nullptr);
                }
                for (int j = 0; j < OldLibrary->Images.size(); j++)
                {
                    MLibraryV0::MImage *oldimage = OldLibrary->GetMImage(j);
                    MLibraryV2::MImage *tempVar = new MLibraryV2::MImage(oldimage->FBytes, oldimage->Width, oldimage->Height);
                    tempVar->X = oldimage->X;
                    tempVar->Y = oldimage->Y;
                    NewLibrary->Images[j] = tempVar;

                    delete tempVar;
                }
                NewLibrary->Save();
                for (int i = 0; i < NewLibrary->Images.size(); i++)
                {
                    if (NewLibrary->Images[i]->Preview != nullptr)
                    {
                        NewLibrary->Images[i]->Preview.Dispose();
                    }
                    if (NewLibrary->Images[i]->Image != nullptr)
                    {
                        NewLibrary->Images[i]->Image.Dispose();
                    }
                    if (NewLibrary->Images[i]->MaskImage != nullptr)
                    {
                        NewLibrary->Images[i]->MaskImage.Dispose();
                    }
                }
                for (int i = 0; i < OldLibrary->Images.size(); i++)
                {
                    if (OldLibrary->Images[i]->Preview != nullptr)
                    {
                        OldLibrary->Images[i]->Preview.Dispose();
                    }
                    if (OldLibrary->Images[i]->Image != nullptr)
                    {
                        OldLibrary->Images[i]->Image.Dispose();
                    }
                }
                NewLibrary->Images.clear();
                NewLibrary->IndexList.clear();
                OldLibrary->Images.clear();
                OldLibrary->IndexList.clear();
                NewLibrary->Close();
                OldLibrary->Close();
                NewLibrary = nullptr;
                OldLibrary = nullptr;

                delete NewLibrary;
                delete OldLibrary;
            }

            // Recurse into subdirectories of this directory.
            std::vector<std::string> subdirEntries = Directory::GetDirectories(sourceDir);
            for (auto subdir : subdirEntries)
            {
                // Do not iterate through re-parse points.
                if (FileSystem::getFileName(FileSystem::getFullPath(subdir)->TrimEnd(FileSystem::preferredSeparator())) == FileSystem::getFileName(FileSystem::getFullPath(outputDir)->TrimEnd(FileSystem::preferredSeparator())))
                {
                    continue;
                }
                if ((File::GetAttributes(subdir) & FileAttributes::ReparsePoint) != FileAttributes::ReparsePoint)
                {
                    ProcessDir(subdir, recursionLvl + 1, outputDir + " \\" + FileSystem::getFileName(FileSystem::getFullPath(subdir)->TrimEnd(FileSystem::preferredSeparator())) + "\\");
                }
            }
        }
    }

    void LMain::ExportButton_Click(std::any sender, EventArgs *e)
    {
        if (_library == nullptr)
        {
            return;
        }
        if (_library->FileName == "")
        {
            return;
        }
        if (PreviewListView->SelectedIndices->Count == 0)
        {
            return;
        }

        std::string _fileName = FileSystem::getFileName(OpenLibraryDialog->FileName);
//C# TO C++ CONVERTER TODO TASK: There is no C++ equivalent to the .NET String 'Remove' method unless assigning to the string instance:
        std::string _newName = _fileName.Remove((int)_fileName.find('.'));
        std::string _folder = Application::StartupPath + "\\Exported\\" + _newName + "\\";

        Bitmap *blank = new Bitmap(1, 1);

        // Create the folder if it doesn't exist.
        FileInfo tempVar(_folder);
        (&tempVar)->Directory->Create();

        ListView::SelectedIndexCollection *_col = PreviewListView->SelectedIndices;

        toolStripProgressBar->Value = 0;
        toolStripProgressBar->Maximum = _col->Count;

        for (int i = _col[0]; i < (_col[0] + _col->Count); i++)
        {
            _exportImage = _library->GetMImage(i);
            if (_exportImage->Image == nullptr)
            {
                blank->Save(_folder + std::to_string(i) + ".bmp", ImageFormat::Bmp);
            }
            else
            {
                _exportImage->Image->Save(_folder + std::to_string(i) + ".bmp", ImageFormat::Bmp);
            }

            toolStripProgressBar->Value++;

            if (!FileSystem::directoryExists(_folder + "/Placements/"))
            {
                FileSystem::createDirectory(_folder + "/Placements/");
            }

            File::WriteAllLines(_folder + "/Placements/" + std::to_string(i) + ".txt", std::vector<std::string> {std::to_string(_exportImage->X), std::to_string(_exportImage->Y)});
        }

        toolStripProgressBar->Value = 0;
        MessageBox::Show("Saving to " + _folder + "...", "Image Saved", MessageBoxButtons::OK);

        delete blank;
    }

    void LMain::LMain_Resize(std::any sender, EventArgs *e)
    {
        if (splitContainer1->SplitterDistance <= this->Height - 150)
        {
            return;
        }
        if (this->Height - 150 > 0)
        {
            splitContainer1->SplitterDistance = this->Height - 150;
        }
    }

    Image *LMain::ImageBoxZoom(Image *image, Size *size)
    {
        _originalImage = _selectedImage->Image;
        Bitmap *_bmp = new Bitmap(_originalImage, static_cast<int>(_originalImage->Width * size->Width), static_cast<int>(_originalImage->Height * size->Height));
        Graphics *_gfx = Graphics::FromImage(_bmp);

//C# TO C++ CONVERTER TODO TASK: A 'delete _bmp' statement was not added since _bmp was passed to a method or constructor. Handle memory management manually.
        return _bmp;
    }

    void LMain::ZoomTrackBar_Scroll(std::any sender, EventArgs *e)
    {
        if (ImageBox->Image == nullptr)
        {
            ZoomTrackBar->Value = 1;
        }
        if (ZoomTrackBar->Value > 0)
        {
            try
            {
                PreviewListView->Items[static_cast<int>(nudJump->Value)]->EnsureVisible();

                Bitmap *_newBMP = new Bitmap(_selectedImage->Width * ZoomTrackBar->Value, _selectedImage->Height * ZoomTrackBar->Value);
//C# TO C++ CONVERTER NOTE: The following 'using' block is replaced by its C++ equivalent:
//ORIGINAL LINE: using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(_newBMP))
                {
                    System::Drawing::Graphics g = System::Drawing::Graphics::FromImage(_newBMP);
                    if (checkBoxPreventAntiAliasing->Checked == true)
                    {
                        g.InterpolationMode = InterpolationMode::HighQualityBicubic;
                        g.CompositingMode = CompositingMode::SourceCopy;
                    }

                    if (checkBoxQuality->Checked == true)
                    {
                        g.InterpolationMode = InterpolationMode::NearestNeighbor;
                    }

                    Rectangle tempVar(0, 0, _newBMP->Width, _newBMP->Height);
                    g.DrawImage(_selectedImage->Image, &tempVar);
                }
                ImageBox->Image = _newBMP;

                toolStripStatusLabel->ForeColor = SystemColors::ControlText;
//C# TO C++ CONVERTER TODO TASK: There is no C++ equivalent to 'ToString':
                toolStripStatusLabel->Text = "Selected Image: " + StringHelper::formatSimple("{0} / {1}", PreviewListView->SelectedIndices[0].ToString(), std::to_string(PreviewListView->Items->Count - 1));

//C# TO C++ CONVERTER TODO TASK: A 'delete _newBMP' statement was not added since _newBMP was passed to a method or constructor. Handle memory management manually.
            }
            catch (...)
            {
                return;
            }
        }
    }

    void LMain::pictureBox_Click(std::any sender, EventArgs *e)
    {
        if (panel->BackColor == Color::Black)
        {
            panel->BackColor = Color::GhostWhite;
        }
        else
        {
            panel->BackColor = Color::Black;
        }
    }

    void LMain::PreviewListView_VirtualItemsSelectionRangeChanged(std::any sender, ListViewVirtualItemsSelectionRangeChangedEventArgs *e)
    {
        // Keep track of what image/s are selected.
        ListView::SelectedIndexCollection *_col = PreviewListView->SelectedIndices;

        if (_col->Count > 1)
        {
            toolStripStatusLabel->ForeColor = Color::Red;
            toolStripStatusLabel->Text = "Multiple images selected.";
        }
    }

    void LMain::buttonReplace_Click(std::any sender, EventArgs *e)
    {
        if (_library == nullptr)
        {
            return;
        }
        if (_library->FileName == "")
        {
            return;
        }
        if (PreviewListView->SelectedIndices->Count == 0)
        {
            return;
        }

        OpenFileDialog *ofd = new OpenFileDialog();
        ofd->ShowDialog();

        if (ofd->FileName == "")
        {
            delete ofd;
            return;
        }

        Bitmap *newBmp = new Bitmap(ofd->FileName);

        ImageList->Images->Clear();
        _indexList.clear();
        _library->ReplaceImage(PreviewListView->SelectedIndices[0], newBmp, 0, 0);
        PreviewListView->VirtualListSize = _library->Images.size();

        try
        {
            PreviewListView->RedrawItems(0, PreviewListView->Items->Count - 1, true);
            ImageBox->Image = _library->Images[PreviewListView->SelectedIndices[0]]->Image;
        }
        catch (const std::runtime_error &e1)
        {
//C# TO C++ CONVERTER TODO TASK: A 'delete newBmp' statement was not added since newBmp was passed to a method or constructor. Handle memory management manually.
            delete ofd;
            return;
        }

//C# TO C++ CONVERTER TODO TASK: A 'delete newBmp' statement was not added since newBmp was passed to a method or constructor. Handle memory management manually.
        delete ofd;
    }

    void LMain::previousImageToolStripMenuItem_Click(std::any sender, EventArgs *e)
    {
        try
        {
            if (PreviewListView->Visible && PreviewListView->Items->Count > 0)
            {
                int index = PreviewListView->SelectedIndices[0];
                index = index - 1;
                PreviewListView->SelectedIndices->Clear();
                this->PreviewListView->Items[index]->Selected = true;
                PreviewListView->Items[index]->EnsureVisible();

                if (_selectedImage->Height == 1 && _selectedImage->Width == 1 && PreviewListView->SelectedIndices[0] != 0)
                {
                    previousImageToolStripMenuItem_Click(std::any(), nullptr);
                }
            }
        }
        catch (const std::runtime_error &e1)
        {
            PreviewListView->SelectedIndices->Clear();
            this->PreviewListView->Items[PreviewListView->Items->Count - 1]->Selected = true;
        }
    }

    void LMain::nextImageToolStripMenuItem_Click(std::any sender, EventArgs *e)
    {
        try
        {
            if (PreviewListView->Visible && PreviewListView->Items->Count > 0)
            {
                int index = PreviewListView->SelectedIndices[0];
                index = index + 1;
                PreviewListView->SelectedIndices->Clear();
                this->PreviewListView->Items[index]->Selected = true;
                PreviewListView->Items[index]->EnsureVisible();

                if (_selectedImage->Height == 1 && _selectedImage->Width == 1 && PreviewListView->SelectedIndices[0] != 0)
                {
                    nextImageToolStripMenuItem_Click(std::any(), nullptr);
                }
            }
        }
        catch (const std::runtime_error &e1)
        {
            PreviewListView->SelectedIndices->Clear();
            this->PreviewListView->Items[0]->Selected = true;
        }
    }

    bool LMain::ProcessCmdKey(Message *&msg, Keys *keyData)
    {
        if (!ImageTabActive)
        {
            return false;
        }

        if (keyData == Keys->Left)
        {
            previousImageToolStripMenuItem_Click(std::any(), nullptr);
            return true;
        }

        if (keyData == Keys->Right)
        {
            nextImageToolStripMenuItem_Click(std::any(), nullptr);
            return true;
        }

        if (keyData == Keys->Up) //Not 100% accurate but works for now.
        {
            double d = std::floor(static_cast<double>(PreviewListView->Width / 67));
            int index = PreviewListView->SelectedIndices[0] - static_cast<int>(d);

            PreviewListView->SelectedIndices->Clear();
            if (index < 0)
            {
                index = 0;
            }

            this->PreviewListView->Items[index]->Selected = true;

            return true;
        }

        if (keyData == Keys->Down) //Not 100% accurate but works for now.
        {
            double d = std::floor(static_cast<double>(PreviewListView->Width / 67));
            int index = PreviewListView->SelectedIndices[0] + static_cast<int>(d);

            PreviewListView->SelectedIndices->Clear();
            if (index > PreviewListView->Items->Count - 1)
            {
                index = PreviewListView->Items->Count - 1;
            }

            this->PreviewListView->Items[index]->Selected = true;

            return true;
        }

        return System::Windows::Forms::Form::ProcessCmdKey(msg, keyData);
    }

    void LMain::buttonSkipNext_Click(std::any sender, EventArgs *e)
    {
        nextImageToolStripMenuItem_Click(std::any(), nullptr);
    }

    void LMain::buttonSkipPrevious_Click(std::any sender, EventArgs *e)
    {
        previousImageToolStripMenuItem_Click(std::any(), nullptr);
    }

    void LMain::checkBoxQuality_CheckedChanged(std::any sender, EventArgs *e)
    {
        ZoomTrackBar_Scroll(std::any(), nullptr);
    }

    void LMain::checkBoxPreventAntiAliasing_CheckedChanged(std::any sender, EventArgs *e)
    {
        ZoomTrackBar_Scroll(std::any(), nullptr);
    }

    void LMain::nudJump_ValueChanged(std::any sender, EventArgs *e)
    {
        if (PreviewListView->Items->Count - 1 >= nudJump->Value)
        {
            PreviewListView->SelectedIndices->Clear();
            PreviewListView->Items[static_cast<int>(nudJump->Value)]->Selected = true;
            PreviewListView->Items[static_cast<int>(nudJump->Value)]->EnsureVisible();
        }
    }

    void LMain::nudJump_KeyDown(std::any sender, KeyEventArgs *e)
    {
        if (e->KeyCode == Keys->Enter)
        {
            //Enter key is down.
            if (PreviewListView->Items->Count - 1 >= nudJump->Value)
            {
                PreviewListView->SelectedIndices->Clear();
                PreviewListView->Items[static_cast<int>(nudJump->Value)]->Selected = true;
                PreviewListView->Items[static_cast<int>(nudJump->Value)]->EnsureVisible();
            }
            e->Handled = true;
            e->SuppressKeyPress = true;
        }
    }

    void LMain::defaultMonsterFramesToolStripMenuItem_Click(std::any sender, EventArgs *e)
    {
        _library->Frames->clear();
        _library->Frames = new FrameSet(FrameSet::DefaultMonsterFrameSet);

        UpdateFrameGridView();
    }

    void LMain::defaultNPCFramesToolStripMenuItem_Click(std::any sender, EventArgs *e)
    {
        _library->Frames->clear();
        _library->Frames = new FrameSet(FrameSet::DefaultNPCFrameSet);

        UpdateFrameGridView();
    }

    void LMain::defaultPlayerFramesToolStripMenuItem_Click(std::any sender, EventArgs *e)
    {
        throw NotImplementedException();
    }

    void LMain::tabControl_SelectedIndexChanged(std::any sender, EventArgs *e)
    {
        switch (tabControl->SelectedIndex)
        {
            case 0: //Images
                ImageTabActive = true;
                FrameTabActive = false;
                ImageBox->Location = new Point(0, 0);
                FrameAnimTimer->Stop();
                break;
            case 1: //Frames
                ImageTabActive = false;
                FrameTabActive = true;
                break;
        }
    }

    void LMain::autofillNpcFramesToolStripMenuItem_Click(std::any sender, EventArgs *e)
    {
        if (FolderLibraryDialog->ShowDialog() != System::Windows::Forms::DialogResult::OK)
        {
            return;
        }

        auto path = FolderLibraryDialog->SelectedPath;

        auto files = Directory::GetFiles(path, "*.Lib");

        if (MessageBox::Show(StringHelper::formatSimple("Are you sure you want to populate {0} Libs with their matching FrameSet?", files.size()()), "Autofill Libs.", MessageBoxButtons::YesNo) != System::Windows::Forms::DialogResult::Yes)
        {
            return;
        }

        for (auto file : files)
        {
            if (_library != nullptr)
            {
                _library->Close();
            }
            _library = new MLibraryV2(file);

            // Show .Lib path in application title.
            this->Text = file;

            auto name = Path::GetFileNameWithoutExtension(file);

            int imageNumber;
            if (!int::TryParse(name, imageNumber))
            {
                continue;
            }

            _library->Frames = GetFrameSetByImage(static_cast<Monster>(imageNumber));
            _library->Save();
        }
    }

    void LMain::frameGridView_CellValidating(std::any sender, DataGridViewCellValidatingEventArgs *e)
    {
        frameGridView->Rows[e->RowIndex]->ErrorText = "";

        if (frameGridView->Rows[e->RowIndex].IsNewRow)
        {
            return;
        }

        if (e->ColumnIndex >= 1 && e->ColumnIndex <= 8)
        {
//C# TO C++ CONVERTER TODO TASK: There is no C++ equivalent to 'ToString':
            if (!int::TryParse(e->FormattedValue.ToString(), _))
            {
                e->Cancel = true;
                frameGridView->Rows[e->RowIndex]->ErrorText = "the value must be an integer";
            }
        }
    }

    void LMain::frameGridView_DefaultValuesNeeded(std::any sender, DataGridViewRowEventArgs *e)
    {
        e->Row.Cells["FrameStart"]->Value = 0;
        e->Row.Cells["FrameCount"]->Value = 0;
        e->Row.Cells["FrameSkip"]->Value = 0;
        e->Row.Cells["FrameInterval"]->Value = 0;
        e->Row.Cells["FrameEffectStart"]->Value = 0;
        e->Row.Cells["FrameEffectCount"]->Value = 0;
        e->Row.Cells["FrameEffectSkip"]->Value = 0;
        e->Row.Cells["FrameEffectInterval"]->Value = 0;
        e->Row.Cells["FrameReverse"]->Value = false;
        e->Row.Cells["FrameBlend"]->Value = false;
    }

    void LMain::UpdateFrameGridView()
    {
        frameGridView->Rows->Clear();

        for (auto action : *_library->Frames)
        {
            auto frame = _library->Frames[action->first];

            int rowIndex = frameGridView->Rows->Add();

            auto row = frameGridView->Rows[rowIndex];

            row->Cells["FrameAction"]->Value = action->first;
            row->Cells["FrameStart"]->Value = frame->getStart();
            row->Cells["FrameCount"]->Value = frame->getCount();
            row->Cells["FrameSkip"]->Value = frame->getSkip();
            row->Cells["FrameInterval"]->Value = frame->getInterval();
            row->Cells["FrameEffectStart"]->Value = frame->getEffectStart();
            row->Cells["FrameEffectCount"]->Value = frame->getEffectCount();
            row->Cells["FrameEffectSkip"]->Value = frame->getEffectSkip();
            row->Cells["FrameEffectInterval"]->Value = frame->getEffectInterval();
            row->Cells["FrameReverse"]->Value = frame->getReverse();
            row->Cells["FrameBlend"]->Value = frame->getBlend();
        }
    }

    void LMain::UpdateFrameGridData()
    {
        if (_library == nullptr)
        {
            return;
        }

        _library->Frames->clear();

        for (DataGridViewRow *row : *frameGridView->Rows)
        {
            auto cells = row->Cells;

            if (cells["FrameAction"]->Value == nullptr)
            {
                continue;
            }

            auto action = static_cast<MirAction>(row->Cells["FrameAction"]->Value);

            if (_library->Frames->find(action) != _library->Frames->end())
            {
                MessageBox::Show(StringHelper::formatSimple(StringHelper::formatSimple("The action '{0}' exists more than once so will not be saved.", action)));
                continue;
            }

            auto frame = new Frame(cells["FrameStart"]->Value->ValueOrDefault<int>(), cells["FrameCount"]->Value->ValueOrDefault<int>(), cells["FrameSkip"]->Value->ValueOrDefault<int>(), cells["FrameInterval"]->Value->ValueOrDefault<int>(), cells["FrameEffectStart"]->Value->ValueOrDefault<int>(), cells["FrameEffectCount"]->Value->ValueOrDefault<int>(), cells["FrameEffectSkip"]->Value->ValueOrDefault<int>(), cells["FrameEffectInterval"]->Value->ValueOrDefault<int>());
            frame->setReverse(cells["FrameReverse"]->Value->ValueOrDefault<bool>());
            frame->setBlend(cells["FrameBlend"]->Value->ValueOrDefault<bool>());

            _library->Frames->emplace(action, frame);

//C# TO C++ CONVERTER TODO TASK: A 'delete frame' statement was not added since frame was passed to a method or constructor. Handle memory management manually.
        }
    }

    void LMain::frameGridView_RowEnter(std::any sender, DataGridViewCellEventArgs *e)
    {
        auto row = frameGridView->Rows[e->RowIndex];

        if (row == nullptr)
        {
            return;
        }

        auto cells = row->Cells;

        if (cells["FrameAction"]->Value == nullptr)
        {
            return;
        }

        auto frame = new Frame(cells["FrameStart"]->Value->ValueOrDefault<int>(), cells["FrameCount"]->Value->ValueOrDefault<int>(), cells["FrameSkip"]->Value->ValueOrDefault<int>(), cells["FrameInterval"]->Value->ValueOrDefault<int>(), cells["FrameEffectStart"]->Value->ValueOrDefault<int>(), cells["FrameEffectCount"]->Value->ValueOrDefault<int>(), cells["FrameEffectSkip"]->Value->ValueOrDefault<int>(), cells["FrameEffectInterval"]->Value->ValueOrDefault<int>());
        frame->setReverse(cells["FrameReverse"]->Value->ValueOrDefault<bool>());
        frame->setBlend(cells["FrameBlend"]->Value->ValueOrDefault<bool>());


        _drawFrame = frame;

        FrameAnimTimer->Interval = frame->getInterval();
        FrameAnimTimer->Start();

//C# TO C++ CONVERTER TODO TASK: A 'delete frame' statement was not added since frame was assigned to a field. Handle memory management manually.
    }

    void LMain::FrameAnimTimer_Tick(std::any sender, EventArgs *e)
    {
        if (_drawFrame == nullptr)
        {
            return;
        }

        try
        {
            if (_currentFrame >= _drawFrame->getCount() - 1)
            {
                _currentFrame = 0;
//C# TO C++ CONVERTER TODO TASK: There is no C++ equivalent to the C# 'typeof' operator:
                std::vector<MirDirection> arr = static_cast<std::vector<MirDirection>>(Enum::GetValues(typeof(MirDirection)));
                int j = Array::IndexOf<MirDirection>(arr, _currentDirection) + 1;
                _currentDirection = (arr.size() == j) ? arr[0] : arr[j];
            }

            auto drawFrame = _drawFrame->getStart() + (_drawFrame->getOffSet() * static_cast<unsigned char>(_currentDirection)) + _currentFrame;

            _selectedImage = _library->GetMImage(drawFrame);

            ImageBox->Location = new Point(250 + _selectedImage->X, 250 + _selectedImage->Y);
            ImageBox->Image = _selectedImage->Image;

            _currentFrame++;
        }
        catch (...)
        {
        }
    }

    FrameSet *LMain::GetFrameSetByImage(Monster image)
    {
        //REMOVE THE BELOW EXCEPTION ONCE THE DESIRED CODE HAS BEEN ADDED          
        throw NotImplementedException("The method 'GetFrameSetByImage' must be updated before this function can be used");

        //UNCOMMENT THE CODE BELOW, IT SERVES AS AN EXAMPLE OF HOW TO MATCH IMAGES UP TO THE CORRECT FRAMES
        //List<FrameSet> FrameList = new List<FrameSet>();
        //FrameSet frame;

        ////ADD LIST OF FRAMES (CAN BE COPIED FROM THE CLIENTS FRAME.CS)
        //FrameList.Add(frame = new FrameSet());
        //frame.Add(MirAction.Standing, new Frame(0, 4, 0, 450));
        //frame.Add(MirAction.Harvest, new Frame(12, 10, 0, 200));

        ////ADD SWITCH OF IMAGE TO CORRECT FRAME (CAN BE COPIED FROM THE MONSTEROBJECT.CS FRAME LIST)
        //FrameSet matchingFrame = new FrameSet();
        //switch (image)
        //{
        //    case Monster.Hen:
        //        matchingFrame = FrameList[0];
        //        break;
        //}

        //return matchingFrame;
    }

    void LMain::Dispose(bool disposing)
    {
        if (disposing && (components != nullptr))
        {
            components->Dispose();
        }
        System::Windows::Forms::Form::Dispose(disposing);
    }

    void LMain::InitializeComponent()
    {
        this->components = new System::ComponentModel::Container();
//C# TO C++ CONVERTER TODO TASK: There is no C++ equivalent to the C# 'typeof' operator:
        System::ComponentModel::ComponentResourceManager *resources = new System::ComponentModel::ComponentResourceManager(typeof(LMain));
        this->MainMenu = new System::Windows::Forms::MenuStrip();
        this->fileToolStripMenuItem = new System::Windows::Forms::ToolStripMenuItem();
        this->newToolStripMenuItem = new System::Windows::Forms::ToolStripMenuItem();
        this->openToolStripMenuItem = new System::Windows::Forms::ToolStripMenuItem();
        this->toolStripMenuItem1 = new System::Windows::Forms::ToolStripSeparator();
        this->saveToolStripMenuItem = new System::Windows::Forms::ToolStripMenuItem();
        this->saveAsToolStripMenuItem = new System::Windows::Forms::ToolStripMenuItem();
        this->toolStripMenuItem2 = new System::Windows::Forms::ToolStripSeparator();
        this->closeToolStripMenuItem = new System::Windows::Forms::ToolStripMenuItem();
        this->functionsToolStripMenuItem = new System::Windows::Forms::ToolStripMenuItem();
        this->copyToToolStripMenuItem = new System::Windows::Forms::ToolStripMenuItem();
        this->countBlanksToolStripMenuItem = new System::Windows::Forms::ToolStripMenuItem();
        this->removeBlanksToolStripMenuItem = new System::Windows::Forms::ToolStripMenuItem();
        this->safeToolStripMenuItem = new System::Windows::Forms::ToolStripMenuItem();
        this->convertToolStripMenuItem = new System::Windows::Forms::ToolStripMenuItem();
        this->populateFramesToolStripMenuItem = new System::Windows::Forms::ToolStripMenuItem();
        this->defaultMonsterFramesToolStripMenuItem = new System::Windows::Forms::ToolStripMenuItem();
        this->defaultNPCFramesToolStripMenuItem = new System::Windows::Forms::ToolStripMenuItem();
        this->defaultPlayerFramesToolStripMenuItem = new System::Windows::Forms::ToolStripMenuItem();
        this->autofillFromCodeToolStripMenuItem = new System::Windows::Forms::ToolStripMenuItem();
        this->skinToolStripMenuItem = new System::Windows::Forms::ToolStripMenuItem();
        this->splitContainer1 = new System::Windows::Forms::SplitContainer();
        this->splitContainer2 = new System::Windows::Forms::SplitContainer();
        this->nudJump = new System::Windows::Forms::NumericUpDown();
        this->checkBoxPreventAntiAliasing = new System::Windows::Forms::CheckBox();
        this->checkBoxQuality = new System::Windows::Forms::CheckBox();
        this->buttonSkipPrevious = new System::Windows::Forms::Button();
        this->buttonSkipNext = new System::Windows::Forms::Button();
        this->buttonReplace = new System::Windows::Forms::Button();
        this->pictureBox = new System::Windows::Forms::PictureBox();
        this->ZoomTrackBar = new System::Windows::Forms::TrackBar();
        this->ExportButton = new System::Windows::Forms::Button();
        this->InsertImageButton = new System::Windows::Forms::Button();
        this->OffSetYTextBox = new System::Windows::Forms::TextBox();
        this->OffSetXTextBox = new System::Windows::Forms::TextBox();
        this->DeleteButton = new System::Windows::Forms::Button();
        this->AddButton = new System::Windows::Forms::Button();
        this->label10 = new System::Windows::Forms::Label();
        this->label8 = new System::Windows::Forms::Label();
        this->HeightLabel = new System::Windows::Forms::Label();
        this->label6 = new System::Windows::Forms::Label();
        this->WidthLabel = new System::Windows::Forms::Label();
        this->label1 = new System::Windows::Forms::Label();
        this->panel = new System::Windows::Forms::Panel();
        this->ImageBox = new System::Windows::Forms::PictureBox();
        this->tabControl = new System::Windows::Forms::TabControl();
        this->tabImages = new System::Windows::Forms::TabPage();
        this->PreviewListView = new CustomFormControl::FixedListView();
        this->ImageList = new System::Windows::Forms::ImageList(this->components);
        this->tabFrames = new System::Windows::Forms::TabPage();
        this->frameGridView = new System::Windows::Forms::DataGridView();
        this->FrameAction = new System::Windows::Forms::DataGridViewComboBoxColumn();
        this->FrameStart = new System::Windows::Forms::DataGridViewTextBoxColumn();
        this->FrameCount = new System::Windows::Forms::DataGridViewTextBoxColumn();
        this->FrameSkip = new System::Windows::Forms::DataGridViewTextBoxColumn();
        this->FrameInterval = new System::Windows::Forms::DataGridViewTextBoxColumn();
        this->FrameEffectStart = new System::Windows::Forms::DataGridViewTextBoxColumn();
        this->FrameEffectCount = new System::Windows::Forms::DataGridViewTextBoxColumn();
        this->FrameEffectSkip = new System::Windows::Forms::DataGridViewTextBoxColumn();
        this->FrameEffectInterval = new System::Windows::Forms::DataGridViewTextBoxColumn();
        this->FrameReverse = new System::Windows::Forms::DataGridViewCheckBoxColumn();
        this->FrameBlend = new System::Windows::Forms::DataGridViewCheckBoxColumn();
        this->OpenLibraryDialog = new System::Windows::Forms::OpenFileDialog();
        this->SaveLibraryDialog = new System::Windows::Forms::SaveFileDialog();
        this->ImportImageDialog = new System::Windows::Forms::OpenFileDialog();
        this->OpenWeMadeDialog = new System::Windows::Forms::OpenFileDialog();
        this->toolTip = new System::Windows::Forms::ToolTip(this->components);
        this->statusStrip = new System::Windows::Forms::StatusStrip();
        this->toolStripStatusLabel = new System::Windows::Forms::ToolStripStatusLabel();
        this->toolStripProgressBar = new System::Windows::Forms::ToolStripProgressBar();
        this->FolderLibraryDialog = new System::Windows::Forms::FolderBrowserDialog();
        this->FrameAnimTimer = new System::Windows::Forms::Timer(this->components);
        this->MainMenu->SuspendLayout();
        (static_cast<System::ComponentModel::ISupportInitialize*>(this->splitContainer1))->BeginInit();
        this->splitContainer1->Panel1.SuspendLayout();
        this->splitContainer1->Panel2.SuspendLayout();
        this->splitContainer1->SuspendLayout();
        (static_cast<System::ComponentModel::ISupportInitialize*>(this->splitContainer2))->BeginInit();
        this->splitContainer2->Panel1.SuspendLayout();
        this->splitContainer2->Panel2.SuspendLayout();
        this->splitContainer2->SuspendLayout();
        (static_cast<System::ComponentModel::ISupportInitialize*>(this->nudJump))->BeginInit();
        (static_cast<System::ComponentModel::ISupportInitialize*>(this->pictureBox))->BeginInit();
        (static_cast<System::ComponentModel::ISupportInitialize*>(this->ZoomTrackBar))->BeginInit();
        this->panel->SuspendLayout();
        (static_cast<System::ComponentModel::ISupportInitialize*>(this->ImageBox))->BeginInit();
        this->tabControl->SuspendLayout();
        this->tabImages->SuspendLayout();
        this->tabFrames->SuspendLayout();
        (static_cast<System::ComponentModel::ISupportInitialize*>(this->frameGridView))->BeginInit();
        this->statusStrip->SuspendLayout();
        this->SuspendLayout();
        // 
        // MainMenu
        // 
        this->MainMenu->Items->AddRange(std::vector<System::Windows::Forms::ToolStripItem*> {this->fileToolStripMenuItem, this->functionsToolStripMenuItem, this->skinToolStripMenuItem});
        this->MainMenu->Location = new System::Drawing::Point(0, 0);
        this->MainMenu->Name = "MainMenu";
        this->MainMenu->RenderMode = System::Windows::Forms::ToolStripRenderMode::Professional;
        this->MainMenu->Size = new System::Drawing::Size(1036, 24);
        this->MainMenu->TabIndex = 0;
        this->MainMenu->Text = "menuStrip1";
        // 
        // fileToolStripMenuItem
        // 
        this->fileToolStripMenuItem->DropDownItems->AddRange(std::vector<System::Windows::Forms::ToolStripItem*> {this->newToolStripMenuItem, this->openToolStripMenuItem, this->toolStripMenuItem1, this->saveToolStripMenuItem, this->saveAsToolStripMenuItem, this->toolStripMenuItem2, this->closeToolStripMenuItem});
        this->fileToolStripMenuItem->Image = (std::any_cast<System::Drawing::Image*>(resources->GetObject("fileToolStripMenuItem.Image")));
        this->fileToolStripMenuItem->Name = "fileToolStripMenuItem";
        this->fileToolStripMenuItem->Size = new System::Drawing::Size(53, 20);
        this->fileToolStripMenuItem->Text = "File";
        // 
        // newToolStripMenuItem
        // 
        this->newToolStripMenuItem->Image = (std::any_cast<System::Drawing::Image*>(resources->GetObject("newToolStripMenuItem.Image")));
        this->newToolStripMenuItem->Name = "newToolStripMenuItem";
        this->newToolStripMenuItem->Size = new System::Drawing::Size(114, 22);
        this->newToolStripMenuItem->Text = "New";
        this->newToolStripMenuItem->ToolTipText = "New .Lib";
        this->newToolStripMenuItem->Click += new System::EventHandler(this->newToolStripMenuItem_Click);
        // 
        // openToolStripMenuItem
        // 
        this->openToolStripMenuItem->Image = (std::any_cast<System::Drawing::Image*>(resources->GetObject("openToolStripMenuItem.Image")));
        this->openToolStripMenuItem->Name = "openToolStripMenuItem";
        this->openToolStripMenuItem->Size = new System::Drawing::Size(114, 22);
        this->openToolStripMenuItem->Text = "Open";
        this->openToolStripMenuItem->ToolTipText = "Open Shanda or Wemade files.";
        this->openToolStripMenuItem->Click += new System::EventHandler(this->openToolStripMenuItem_Click);
        // 
        // toolStripMenuItem1
        // 
        this->toolStripMenuItem1->Name = "toolStripMenuItem1";
        this->toolStripMenuItem1->Size = new System::Drawing::Size(111, 6);
        // 
        // saveToolStripMenuItem
        // 
        this->saveToolStripMenuItem->Image = (std::any_cast<System::Drawing::Image*>(resources->GetObject("saveToolStripMenuItem.Image")));
        this->saveToolStripMenuItem->Name = "saveToolStripMenuItem";
        this->saveToolStripMenuItem->Size = new System::Drawing::Size(114, 22);
        this->saveToolStripMenuItem->Text = "Save";
        this->saveToolStripMenuItem->ToolTipText = "Saves currently open .Lib";
        this->saveToolStripMenuItem->Click += new System::EventHandler(this->saveToolStripMenuItem_Click);
        // 
        // saveAsToolStripMenuItem
        // 
        this->saveAsToolStripMenuItem->Image = (std::any_cast<System::Drawing::Image*>(resources->GetObject("saveAsToolStripMenuItem.Image")));
        this->saveAsToolStripMenuItem->Name = "saveAsToolStripMenuItem";
        this->saveAsToolStripMenuItem->Size = new System::Drawing::Size(114, 22);
        this->saveAsToolStripMenuItem->Text = "Save As";
        this->saveAsToolStripMenuItem->ToolTipText = ".Lib Only.";
        this->saveAsToolStripMenuItem->Click += new System::EventHandler(this->saveAsToolStripMenuItem_Click);
        // 
        // toolStripMenuItem2
        // 
        this->toolStripMenuItem2->Name = "toolStripMenuItem2";
        this->toolStripMenuItem2->Size = new System::Drawing::Size(111, 6);
        // 
        // closeToolStripMenuItem
        // 
        this->closeToolStripMenuItem->Image = (std::any_cast<System::Drawing::Image*>(resources->GetObject("closeToolStripMenuItem.Image")));
        this->closeToolStripMenuItem->Name = "closeToolStripMenuItem";
        this->closeToolStripMenuItem->Size = new System::Drawing::Size(114, 22);
        this->closeToolStripMenuItem->Text = "Close";
        this->closeToolStripMenuItem->ToolTipText = "Exit Application.";
        this->closeToolStripMenuItem->Click += new System::EventHandler(this->closeToolStripMenuItem_Click);
        // 
        // functionsToolStripMenuItem
        // 
        this->functionsToolStripMenuItem->DropDownItems->AddRange(std::vector<System::Windows::Forms::ToolStripItem*> {this->copyToToolStripMenuItem, this->countBlanksToolStripMenuItem, this->removeBlanksToolStripMenuItem, this->convertToolStripMenuItem, this->populateFramesToolStripMenuItem});
        this->functionsToolStripMenuItem->Image = (std::any_cast<System::Drawing::Image*>(resources->GetObject("functionsToolStripMenuItem.Image")));
        this->functionsToolStripMenuItem->Name = "functionsToolStripMenuItem";
        this->functionsToolStripMenuItem->Size = new System::Drawing::Size(87, 20);
        this->functionsToolStripMenuItem->Text = "Functions";
        // 
        // copyToToolStripMenuItem
        // 
        this->copyToToolStripMenuItem->Image = (std::any_cast<System::Drawing::Image*>(resources->GetObject("copyToToolStripMenuItem.Image")));
        this->copyToToolStripMenuItem->Name = "copyToToolStripMenuItem";
        this->copyToToolStripMenuItem->Size = new System::Drawing::Size(162, 22);
        this->copyToToolStripMenuItem->Text = "Copy To..";
        this->copyToToolStripMenuItem->ToolTipText = "Copy to a new .Lib or to the end of an exsisting one.";
        this->copyToToolStripMenuItem->Click += new System::EventHandler(this->copyToToolStripMenuItem_Click);
        // 
        // countBlanksToolStripMenuItem
        // 
        this->countBlanksToolStripMenuItem->Image = (std::any_cast<System::Drawing::Image*>(resources->GetObject("countBlanksToolStripMenuItem.Image")));
        this->countBlanksToolStripMenuItem->Name = "countBlanksToolStripMenuItem";
        this->countBlanksToolStripMenuItem->Size = new System::Drawing::Size(162, 22);
        this->countBlanksToolStripMenuItem->Text = "Count Blanks";
        this->countBlanksToolStripMenuItem->ToolTipText = "Counts the blank images in the .Lib";
        this->countBlanksToolStripMenuItem->Click += new System::EventHandler(this->countBlanksToolStripMenuItem_Click);
        // 
        // removeBlanksToolStripMenuItem
        // 
        this->removeBlanksToolStripMenuItem->DropDownItems->AddRange(std::vector<System::Windows::Forms::ToolStripItem*> {this->safeToolStripMenuItem});
        this->removeBlanksToolStripMenuItem->Image = (std::any_cast<System::Drawing::Image*>(resources->GetObject("removeBlanksToolStripMenuItem.Image")));
        this->removeBlanksToolStripMenuItem->Name = "removeBlanksToolStripMenuItem";
        this->removeBlanksToolStripMenuItem->Size = new System::Drawing::Size(162, 22);
        this->removeBlanksToolStripMenuItem->Text = "Remove Blanks";
        this->removeBlanksToolStripMenuItem->ToolTipText = "Quick removal of blanks.";
        this->removeBlanksToolStripMenuItem->Click += new System::EventHandler(this->removeBlanksToolStripMenuItem_Click);
        // 
        // safeToolStripMenuItem
        // 
        this->safeToolStripMenuItem->Image = (std::any_cast<System::Drawing::Image*>(resources->GetObject("safeToolStripMenuItem.Image")));
        this->safeToolStripMenuItem->Name = "safeToolStripMenuItem";
        this->safeToolStripMenuItem->Size = new System::Drawing::Size(96, 22);
        this->safeToolStripMenuItem->Text = "Safe";
        this->safeToolStripMenuItem->ToolTipText = "Use the safe method of removing blanks.";
        this->safeToolStripMenuItem->Click += new System::EventHandler(this->safeToolStripMenuItem_Click);
        // 
        // convertToolStripMenuItem
        // 
        this->convertToolStripMenuItem->Image = (std::any_cast<System::Drawing::Image*>(resources->GetObject("convertToolStripMenuItem.Image")));
        this->convertToolStripMenuItem->Name = "convertToolStripMenuItem";
        this->convertToolStripMenuItem->Size = new System::Drawing::Size(162, 22);
        this->convertToolStripMenuItem->Text = "Converter";
        this->convertToolStripMenuItem->ToolTipText = "Convert Wil/Wzl/Miz to .Lib";
        this->convertToolStripMenuItem->Click += new System::EventHandler(this->convertToolStripMenuItem_Click);
        // 
        // populateFramesToolStripMenuItem
        // 
        this->populateFramesToolStripMenuItem->DropDownItems->AddRange(std::vector<System::Windows::Forms::ToolStripItem*> {this->defaultMonsterFramesToolStripMenuItem, this->defaultNPCFramesToolStripMenuItem, this->defaultPlayerFramesToolStripMenuItem, this->autofillFromCodeToolStripMenuItem});
        this->populateFramesToolStripMenuItem->Image = (std::any_cast<System::Drawing::Image*>(resources->GetObject("populateFramesToolStripMenuItem.Image")));
        this->populateFramesToolStripMenuItem->Name = "populateFramesToolStripMenuItem";
        this->populateFramesToolStripMenuItem->Size = new System::Drawing::Size(162, 22);
        this->populateFramesToolStripMenuItem->Text = "Populate Frames";
        // 
        // defaultMonsterFramesToolStripMenuItem
        // 
        this->defaultMonsterFramesToolStripMenuItem->Image = (std::any_cast<System::Drawing::Image*>(resources->GetObject("defaultMonsterFramesToolStripMenuItem.Image")));
        this->defaultMonsterFramesToolStripMenuItem->Name = "defaultMonsterFramesToolStripMenuItem";
        this->defaultMonsterFramesToolStripMenuItem->Size = new System::Drawing::Size(200, 22);
        this->defaultMonsterFramesToolStripMenuItem->Text = "Default Monster Frames";
        this->defaultMonsterFramesToolStripMenuItem->Click += new System::EventHandler(this->defaultMonsterFramesToolStripMenuItem_Click);
        // 
        // defaultNPCFramesToolStripMenuItem
        // 
        this->defaultNPCFramesToolStripMenuItem->Image = (std::any_cast<System::Drawing::Image*>(resources->GetObject("defaultNPCFramesToolStripMenuItem.Image")));
        this->defaultNPCFramesToolStripMenuItem->Name = "defaultNPCFramesToolStripMenuItem";
        this->defaultNPCFramesToolStripMenuItem->Size = new System::Drawing::Size(200, 22);
        this->defaultNPCFramesToolStripMenuItem->Text = "Default NPC Frames";
        this->defaultNPCFramesToolStripMenuItem->Click += new System::EventHandler(this->defaultNPCFramesToolStripMenuItem_Click);
        // 
        // defaultPlayerFramesToolStripMenuItem
        // 
        this->defaultPlayerFramesToolStripMenuItem->Image = (std::any_cast<System::Drawing::Image*>(resources->GetObject("defaultPlayerFramesToolStripMenuItem.Image")));
        this->defaultPlayerFramesToolStripMenuItem->Name = "defaultPlayerFramesToolStripMenuItem";
        this->defaultPlayerFramesToolStripMenuItem->Size = new System::Drawing::Size(200, 22);
        this->defaultPlayerFramesToolStripMenuItem->Text = "Default Player Frames";
        this->defaultPlayerFramesToolStripMenuItem->Click += new System::EventHandler(this->defaultPlayerFramesToolStripMenuItem_Click);
        // 
        // autofillFromCodeToolStripMenuItem
        // 
        this->autofillFromCodeToolStripMenuItem->Image = (std::any_cast<System::Drawing::Image*>(resources->GetObject("autofillFromCodeToolStripMenuItem.Image")));
        this->autofillFromCodeToolStripMenuItem->Name = "autofillFromCodeToolStripMenuItem";
        this->autofillFromCodeToolStripMenuItem->Size = new System::Drawing::Size(200, 22);
        this->autofillFromCodeToolStripMenuItem->Text = "AutoFill From Code";
        this->autofillFromCodeToolStripMenuItem->Click += new System::EventHandler(this->autofillNpcFramesToolStripMenuItem_Click);
        // 
        // skinToolStripMenuItem
        // 
        this->skinToolStripMenuItem->Alignment = System::Windows::Forms::ToolStripItemAlignment::Right;
        this->skinToolStripMenuItem->Image = (std::any_cast<System::Drawing::Image*>(resources->GetObject("skinToolStripMenuItem.Image")));
        this->skinToolStripMenuItem->Name = "skinToolStripMenuItem";
        this->skinToolStripMenuItem->Size = new System::Drawing::Size(57, 20);
        this->skinToolStripMenuItem->Text = "Skin";
        this->skinToolStripMenuItem->Visible = false;
        // 
        // splitContainer1
        // 
        this->splitContainer1->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;
        this->splitContainer1->Dock = System::Windows::Forms::DockStyle::Fill;
        this->splitContainer1->Location = new System::Drawing::Point(0, 24);
        this->splitContainer1->Name = "splitContainer1";
        this->splitContainer1->Orientation = System::Windows::Forms::Orientation::Horizontal;
        // 
        // splitContainer1.Panel1
        // 
        this->splitContainer1->Panel1.Controls->Add(this->splitContainer2);
        this->splitContainer1->Panel1MinSize = 325;
        // 
        // splitContainer1.Panel2
        // 
        this->splitContainer1->Panel2.Controls->Add(this->tabControl);
        this->splitContainer1->Size = new System::Drawing::Size(1036, 684);
        this->splitContainer1->SplitterDistance = 325;
        this->splitContainer1->TabIndex = 1;
        // 
        // splitContainer2
        // 
        this->splitContainer2->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;
        this->splitContainer2->Dock = System::Windows::Forms::DockStyle::Fill;
        this->splitContainer2->FixedPanel = System::Windows::Forms::FixedPanel::Panel1;
        this->splitContainer2->IsSplitterFixed = true;
        this->splitContainer2->Location = new System::Drawing::Point(0, 0);
        this->splitContainer2->Name = "splitContainer2";
        // 
        // splitContainer2.Panel1
        // 
        this->splitContainer2->Panel1.Controls->Add(this->nudJump);
        this->splitContainer2->Panel1.Controls->Add(this->checkBoxPreventAntiAliasing);
        this->splitContainer2->Panel1.Controls->Add(this->checkBoxQuality);
        this->splitContainer2->Panel1.Controls->Add(this->buttonSkipPrevious);
        this->splitContainer2->Panel1.Controls->Add(this->buttonSkipNext);
        this->splitContainer2->Panel1.Controls->Add(this->buttonReplace);
        this->splitContainer2->Panel1.Controls->Add(this->pictureBox);
        this->splitContainer2->Panel1.Controls->Add(this->ZoomTrackBar);
        this->splitContainer2->Panel1.Controls->Add(this->ExportButton);
        this->splitContainer2->Panel1.Controls->Add(this->InsertImageButton);
        this->splitContainer2->Panel1.Controls->Add(this->OffSetYTextBox);
        this->splitContainer2->Panel1.Controls->Add(this->OffSetXTextBox);
        this->splitContainer2->Panel1.Controls->Add(this->DeleteButton);
        this->splitContainer2->Panel1.Controls->Add(this->AddButton);
        this->splitContainer2->Panel1.Controls->Add(this->label10);
        this->splitContainer2->Panel1.Controls->Add(this->label8);
        this->splitContainer2->Panel1.Controls->Add(this->HeightLabel);
        this->splitContainer2->Panel1.Controls->Add(this->label6);
        this->splitContainer2->Panel1.Controls->Add(this->WidthLabel);
        this->splitContainer2->Panel1.Controls->Add(this->label1);
        this->splitContainer2->Panel1->ForeColor = System::Drawing::Color::Black;
        this->splitContainer2->Panel1MinSize = 240;
        // 
        // splitContainer2.Panel2
        // 
        this->splitContainer2->Panel2.Controls->Add(this->panel);
        this->splitContainer2->Size = new System::Drawing::Size(1036, 325);
        this->splitContainer2->SplitterDistance = 240;
        this->splitContainer2->TabIndex = 0;
        // 
        // nudJump
        // 
        this->nudJump->Location = new System::Drawing::Point(77, 219);
        this->nudJump->Maximum = Decimal(std::vector<int> {650000, 0, 0, 0});
        this->nudJump->Name = "nudJump";
        this->nudJump->Size = new System::Drawing::Size(77, 20);
        this->nudJump->TabIndex = 21;
        this->nudJump->ValueChanged += new System::EventHandler(this->nudJump_ValueChanged);
        this->nudJump->KeyDown += new System::Windows::Forms::KeyEventHandler(this->nudJump_KeyDown);
        // 
        // checkBoxPreventAntiAliasing
        // 
        this->checkBoxPreventAntiAliasing->AutoSize = true;
        this->checkBoxPreventAntiAliasing->Location = new System::Drawing::Point(95, 299);
        this->checkBoxPreventAntiAliasing->Name = "checkBoxPreventAntiAliasing";
        this->checkBoxPreventAntiAliasing->Size = new System::Drawing::Size(99, 17);
        this->checkBoxPreventAntiAliasing->TabIndex = 20;
        this->checkBoxPreventAntiAliasing->Text = "No Anti-aliasing";
        this->checkBoxPreventAntiAliasing->UseVisualStyleBackColor = true;
        this->checkBoxPreventAntiAliasing->CheckedChanged += new System::EventHandler(this->checkBoxPreventAntiAliasing_CheckedChanged);
        // 
        // checkBoxQuality
        // 
        this->checkBoxQuality->AutoSize = true;
        this->checkBoxQuality->Location = new System::Drawing::Point(11, 299);
        this->checkBoxQuality->Name = "checkBoxQuality";
        this->checkBoxQuality->Size = new System::Drawing::Size(78, 17);
        this->checkBoxQuality->TabIndex = 19;
        this->checkBoxQuality->Text = "No Blurring";
        this->checkBoxQuality->UseVisualStyleBackColor = true;
        this->checkBoxQuality->CheckedChanged += new System::EventHandler(this->checkBoxQuality_CheckedChanged);
        // 
        // buttonSkipPrevious
        // 
        this->buttonSkipPrevious->ForeColor = System::Drawing::SystemColors::ControlText;
        this->buttonSkipPrevious->Image = (std::any_cast<System::Drawing::Image*>(resources->GetObject("buttonSkipPrevious.Image")));
        this->buttonSkipPrevious->Location = new System::Drawing::Point(42, 216);
        this->buttonSkipPrevious->Name = "buttonSkipPrevious";
        this->buttonSkipPrevious->Size = new System::Drawing::Size(30, 26);
        this->buttonSkipPrevious->TabIndex = 17;
        this->buttonSkipPrevious->Tag = "";
        this->buttonSkipPrevious->TextImageRelation = System::Windows::Forms::TextImageRelation::TextBeforeImage;
        this->buttonSkipPrevious->UseVisualStyleBackColor = true;
        this->buttonSkipPrevious->Click += new System::EventHandler(this->buttonSkipPrevious_Click);
        // 
        // buttonSkipNext
        // 
        this->buttonSkipNext->ForeColor = System::Drawing::SystemColors::ControlText;
        this->buttonSkipNext->Image = (std::any_cast<System::Drawing::Image*>(resources->GetObject("buttonSkipNext.Image")));
        this->buttonSkipNext->Location = new System::Drawing::Point(159, 216);
        this->buttonSkipNext->Name = "buttonSkipNext";
        this->buttonSkipNext->Size = new System::Drawing::Size(30, 26);
        this->buttonSkipNext->TabIndex = 16;
        this->buttonSkipNext->Tag = "";
        this->buttonSkipNext->TextImageRelation = System::Windows::Forms::TextImageRelation::TextBeforeImage;
        this->buttonSkipNext->UseVisualStyleBackColor = true;
        this->buttonSkipNext->Click += new System::EventHandler(this->buttonSkipNext_Click);
        // 
        // buttonReplace
        // 
        this->buttonReplace->ForeColor = System::Drawing::SystemColors::ControlText;
        this->buttonReplace->Image = (std::any_cast<System::Drawing::Image*>(resources->GetObject("buttonReplace.Image")));
        this->buttonReplace->ImageAlign = System::Drawing::ContentAlignment::MiddleRight;
        this->buttonReplace->Location = new System::Drawing::Point(10, 144);
        this->buttonReplace->Name = "buttonReplace";
        this->buttonReplace->Size = new System::Drawing::Size(105, 26);
        this->buttonReplace->TabIndex = 15;
        this->buttonReplace->Tag = "";
        this->buttonReplace->Text = "Replace Image";
        this->buttonReplace->TextImageRelation = System::Windows::Forms::TextImageRelation::TextBeforeImage;
        this->buttonReplace->UseVisualStyleBackColor = true;
        this->buttonReplace->Click += new System::EventHandler(this->buttonReplace_Click);
        // 
        // pictureBox
        // 
        this->pictureBox->Image = (std::any_cast<System::Drawing::Image*>(resources->GetObject("pictureBox.Image")));
        this->pictureBox->Location = new System::Drawing::Point(10, 9);
        this->pictureBox->Name = "pictureBox";
        this->pictureBox->Size = new System::Drawing::Size(16, 16);
        this->pictureBox->SizeMode = System::Windows::Forms::PictureBoxSizeMode::AutoSize;
        this->pictureBox->TabIndex = 14;
        this->pictureBox->TabStop = false;
        this->toolTip->SetToolTip(this->pictureBox, "Switch from Black to White background.");
        this->pictureBox->Click += new System::EventHandler(this->pictureBox_Click);
        // 
        // ZoomTrackBar
        // 
        this->ZoomTrackBar->LargeChange = 1;
        this->ZoomTrackBar->Location = new System::Drawing::Point(42, 248);
        this->ZoomTrackBar->Minimum = 1;
        this->ZoomTrackBar->Name = "ZoomTrackBar";
        this->ZoomTrackBar->Size = new System::Drawing::Size(147, 45);
        this->ZoomTrackBar->TabIndex = 4;
        this->ZoomTrackBar->TickStyle = System::Windows::Forms::TickStyle::TopLeft;
        this->ZoomTrackBar->Value = 1;
        this->ZoomTrackBar->Scroll += new System::EventHandler(this->ZoomTrackBar_Scroll);
        // 
        // ExportButton
        // 
        this->ExportButton->ForeColor = System::Drawing::SystemColors::ControlText;
        this->ExportButton->Image = (std::any_cast<System::Drawing::Image*>(resources->GetObject("ExportButton.Image")));
        this->ExportButton->ImageAlign = System::Drawing::ContentAlignment::MiddleRight;
        this->ExportButton->Location = new System::Drawing::Point(121, 176);
        this->ExportButton->Name = "ExportButton";
        this->ExportButton->Size = new System::Drawing::Size(105, 26);
        this->ExportButton->TabIndex = 3;
        this->ExportButton->Tag = "";
        this->ExportButton->Text = "Export Images";
        this->ExportButton->TextImageRelation = System::Windows::Forms::TextImageRelation::TextBeforeImage;
        this->ExportButton->UseVisualStyleBackColor = true;
        this->ExportButton->Click += new System::EventHandler(this->ExportButton_Click);
        // 
        // InsertImageButton
        // 
        this->InsertImageButton->ForeColor = System::Drawing::SystemColors::ControlText;
        this->InsertImageButton->Image = (std::any_cast<System::Drawing::Image*>(resources->GetObject("InsertImageButton.Image")));
        this->InsertImageButton->ImageAlign = System::Drawing::ContentAlignment::MiddleRight;
        this->InsertImageButton->Location = new System::Drawing::Point(121, 144);
        this->InsertImageButton->Name = "InsertImageButton";
        this->InsertImageButton->Size = new System::Drawing::Size(105, 26);
        this->InsertImageButton->TabIndex = 1;
        this->InsertImageButton->Tag = "";
        this->InsertImageButton->Text = "Insert Images";
        this->InsertImageButton->TextImageRelation = System::Windows::Forms::TextImageRelation::TextBeforeImage;
        this->InsertImageButton->UseVisualStyleBackColor = true;
        this->InsertImageButton->Click += new System::EventHandler(this->InsertImageButton_Click);
        // 
        // OffSetYTextBox
        // 
        this->OffSetYTextBox->Location = new System::Drawing::Point(123, 76);
        this->OffSetYTextBox->Name = "OffSetYTextBox";
        this->OffSetYTextBox->Size = new System::Drawing::Size(65, 20);
        this->OffSetYTextBox->TabIndex = 6;
        this->OffSetYTextBox->TextChanged += new System::EventHandler(this->OffSetYTextBox_TextChanged);
        // 
        // OffSetXTextBox
        // 
        this->OffSetXTextBox->Location = new System::Drawing::Point(123, 50);
        this->OffSetXTextBox->Name = "OffSetXTextBox";
        this->OffSetXTextBox->Size = new System::Drawing::Size(65, 20);
        this->OffSetXTextBox->TabIndex = 5;
        this->OffSetXTextBox->TextChanged += new System::EventHandler(this->OffSetXTextBox_TextChanged);
        // 
        // DeleteButton
        // 
        this->DeleteButton->ForeColor = System::Drawing::SystemColors::ControlText;
        this->DeleteButton->Image = (std::any_cast<System::Drawing::Image*>(resources->GetObject("DeleteButton.Image")));
        this->DeleteButton->ImageAlign = System::Drawing::ContentAlignment::MiddleRight;
        this->DeleteButton->Location = new System::Drawing::Point(121, 112);
        this->DeleteButton->Name = "DeleteButton";
        this->DeleteButton->Size = new System::Drawing::Size(105, 26);
        this->DeleteButton->TabIndex = 2;
        this->DeleteButton->Tag = "";
        this->DeleteButton->Text = "Delete Images";
        this->DeleteButton->TextImageRelation = System::Windows::Forms::TextImageRelation::TextBeforeImage;
        this->DeleteButton->UseVisualStyleBackColor = true;
        this->DeleteButton->Click += new System::EventHandler(this->DeleteButton_Click);
        // 
        // AddButton
        // 
        this->AddButton->ForeColor = System::Drawing::SystemColors::ControlText;
        this->AddButton->Image = (std::any_cast<System::Drawing::Image*>(resources->GetObject("AddButton.Image")));
        this->AddButton->ImageAlign = System::Drawing::ContentAlignment::MiddleRight;
        this->AddButton->Location = new System::Drawing::Point(10, 112);
        this->AddButton->Name = "AddButton";
        this->AddButton->Size = new System::Drawing::Size(105, 26);
        this->AddButton->TabIndex = 0;
        this->AddButton->Tag = "";
        this->AddButton->Text = "Add Images";
        this->AddButton->TextImageRelation = System::Windows::Forms::TextImageRelation::TextBeforeImage;
        this->AddButton->UseVisualStyleBackColor = true;
        this->AddButton->Click += new System::EventHandler(this->AddButton_Click);
        // 
        // label10
        // 
        this->label10->AutoSize = true;
        this->label10->ForeColor = System::Drawing::SystemColors::ControlText;
        this->label10->Location = new System::Drawing::Point(67, 79);
        this->label10->Name = "label10";
        this->label10->Size = new System::Drawing::Size(50, 13);
        this->label10->TabIndex = 12;
        this->label10->Text = "OffSet Y:";
        // 
        // label8
        // 
        this->label8->AutoSize = true;
        this->label8->ForeColor = System::Drawing::SystemColors::ControlText;
        this->label8->Location = new System::Drawing::Point(67, 53);
        this->label8->Name = "label8";
        this->label8->Size = new System::Drawing::Size(50, 13);
        this->label8->TabIndex = 11;
        this->label8->Text = "OffSet X:";
        // 
        // HeightLabel
        // 
        this->HeightLabel->AutoSize = true;
        this->HeightLabel->ForeColor = System::Drawing::SystemColors::ControlText;
        this->HeightLabel->Location = new System::Drawing::Point(123, 30);
        this->HeightLabel->Name = "HeightLabel";
        this->HeightLabel->Size = new System::Drawing::Size(65, 13);
        this->HeightLabel->TabIndex = 10;
        this->HeightLabel->Text = "<No Image>";
        // 
        // label6
        // 
        this->label6->AutoSize = true;
        this->label6->ForeColor = System::Drawing::SystemColors::ControlText;
        this->label6->Location = new System::Drawing::Point(76, 30);
        this->label6->Name = "label6";
        this->label6->Size = new System::Drawing::Size(41, 13);
        this->label6->TabIndex = 9;
        this->label6->Text = "Height:";
        // 
        // WidthLabel
        // 
        this->WidthLabel->AutoSize = true;
        this->WidthLabel->ForeColor = System::Drawing::SystemColors::ControlText;
        this->WidthLabel->Location = new System::Drawing::Point(123, 12);
        this->WidthLabel->Name = "WidthLabel";
        this->WidthLabel->Size = new System::Drawing::Size(65, 13);
        this->WidthLabel->TabIndex = 8;
        this->WidthLabel->Text = "<No Image>";
        // 
        // label1
        // 
        this->label1->AutoSize = true;
        this->label1->ForeColor = System::Drawing::SystemColors::ControlText;
        this->label1->Location = new System::Drawing::Point(79, 12);
        this->label1->Name = "label1";
        this->label1->Size = new System::Drawing::Size(38, 13);
        this->label1->TabIndex = 7;
        this->label1->Text = "Width:";
        // 
        // panel
        // 
        this->panel->AutoScroll = true;
        this->panel->BackColor = System::Drawing::Color::Black;
        this->panel->BorderStyle = System::Windows::Forms::BorderStyle::Fixed3D;
        this->panel->Controls->Add(this->ImageBox);
        this->panel->Dock = System::Windows::Forms::DockStyle::Fill;
        this->panel->Location = new System::Drawing::Point(0, 0);
        this->panel->Name = "panel";
        this->panel->Size = new System::Drawing::Size(790, 323);
        this->panel->TabIndex = 1;
        // 
        // ImageBox
        // 
        this->ImageBox->BackColor = System::Drawing::Color::Transparent;
        this->ImageBox->Location = new System::Drawing::Point(0, 0);
        this->ImageBox->Name = "ImageBox";
        this->ImageBox->Size = new System::Drawing::Size(64, 64);
        this->ImageBox->SizeMode = System::Windows::Forms::PictureBoxSizeMode::AutoSize;
        this->ImageBox->TabIndex = 0;
        this->ImageBox->TabStop = false;
        // 
        // tabControl
        // 
        this->tabControl->Controls->Add(this->tabImages);
        this->tabControl->Controls->Add(this->tabFrames);
        this->tabControl->Dock = System::Windows::Forms::DockStyle::Fill;
        this->tabControl->Location = new System::Drawing::Point(0, 0);
        this->tabControl->Name = "tabControl";
        this->tabControl->SelectedIndex = 0;
        this->tabControl->Size = new System::Drawing::Size(1034, 353);
        this->tabControl->TabIndex = 0;
        this->tabControl->SelectedIndexChanged += new System::EventHandler(this->tabControl_SelectedIndexChanged);
        // 
        // tabImages
        // 
        this->tabImages->Controls->Add(this->PreviewListView);
        this->tabImages->Location = new System::Drawing::Point(4, 22);
        this->tabImages->Name = "tabImages";
        this->tabImages->Padding = new System::Windows::Forms::Padding(3);
        this->tabImages->Size = new System::Drawing::Size(1026, 327);
        this->tabImages->TabIndex = 0;
        this->tabImages->Text = "Images";
        this->tabImages->UseVisualStyleBackColor = true;
        // 
        // PreviewListView
        // 
        this->PreviewListView->Activation = System::Windows::Forms::ItemActivation::OneClick;
        this->PreviewListView->BackColor = System::Drawing::Color::GhostWhite;
        this->PreviewListView->Dock = System::Windows::Forms::DockStyle::Fill;
        this->PreviewListView->ForeColor = System::Drawing::Color::FromArgb((static_cast<int>((static_cast<unsigned char>(142)))), (static_cast<int>((static_cast<unsigned char>(152)))), (static_cast<int>((static_cast<unsigned char>(156)))));
        this->PreviewListView->HideSelection = false;
        this->PreviewListView->LargeImageList = this->ImageList;
        this->PreviewListView->Location = new System::Drawing::Point(3, 3);
        this->PreviewListView->Name = "PreviewListView";
        this->PreviewListView->Size = new System::Drawing::Size(1020, 321);
        this->PreviewListView->TabIndex = 0;
        this->PreviewListView->UseCompatibleStateImageBehavior = false;
        this->PreviewListView->VirtualMode = true;
        this->PreviewListView->RetrieveVirtualItem += new System::Windows::Forms::RetrieveVirtualItemEventHandler(this->PreviewListView_RetrieveVirtualItem);
        this->PreviewListView->SelectedIndexChanged += new System::EventHandler(this->PreviewListView_SelectedIndexChanged);
        this->PreviewListView->VirtualItemsSelectionRangeChanged += new System::Windows::Forms::ListViewVirtualItemsSelectionRangeChangedEventHandler(this->PreviewListView_VirtualItemsSelectionRangeChanged);
        // 
        // ImageList
        // 
        this->ImageList->ColorDepth = System::Windows::Forms::ColorDepth::Depth32Bit;
        this->ImageList->ImageSize = new System::Drawing::Size(64, 64);
        this->ImageList->TransparentColor = System::Drawing::Color::Transparent;
        // 
        // tabFrames
        // 
        this->tabFrames->Controls->Add(this->frameGridView);
        this->tabFrames->Location = new System::Drawing::Point(4, 22);
        this->tabFrames->Name = "tabFrames";
        this->tabFrames->Size = new System::Drawing::Size(1026, 327);
        this->tabFrames->TabIndex = 1;
        this->tabFrames->Text = "Frames";
        this->tabFrames->UseVisualStyleBackColor = true;
        // 
        // frameGridView
        // 
        this->frameGridView->AutoSizeColumnsMode = System::Windows::Forms::DataGridViewAutoSizeColumnsMode::Fill;
        this->frameGridView->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize;
        this->frameGridView->Columns->AddRange(std::vector<System::Windows::Forms::DataGridViewColumn*> {this->FrameAction, this->FrameStart, this->FrameCount, this->FrameSkip, this->FrameInterval, this->FrameEffectStart, this->FrameEffectCount, this->FrameEffectSkip, this->FrameEffectInterval, this->FrameReverse, this->FrameBlend});
        this->frameGridView->Dock = System::Windows::Forms::DockStyle::Fill;
        this->frameGridView->Location = new System::Drawing::Point(0, 0);
        this->frameGridView->Name = "frameGridView";
        this->frameGridView->Size = new System::Drawing::Size(1026, 327);
        this->frameGridView->TabIndex = 2;
        this->frameGridView->CellValidating += new System::Windows::Forms::DataGridViewCellValidatingEventHandler(this->frameGridView_CellValidating);
        this->frameGridView->DefaultValuesNeeded += new System::Windows::Forms::DataGridViewRowEventHandler(this->frameGridView_DefaultValuesNeeded);
        this->frameGridView->RowEnter += new System::Windows::Forms::DataGridViewCellEventHandler(this->frameGridView_RowEnter);
        // 
        // FrameAction
        // 
        this->FrameAction->HeaderText = "Action";
        this->FrameAction->Name = "FrameAction";
        this->FrameAction->Resizable = System::Windows::Forms::DataGridViewTriState::True;
        this->FrameAction->SortMode = System::Windows::Forms::DataGridViewColumnSortMode::Automatic;
        // 
        // FrameStart
        // 
        this->FrameStart->HeaderText = "Start";
        this->FrameStart->Name = "FrameStart";
        // 
        // FrameCount
        // 
        this->FrameCount->HeaderText = "Count";
        this->FrameCount->Name = "FrameCount";
        // 
        // FrameSkip
        // 
        this->FrameSkip->HeaderText = "Skip";
        this->FrameSkip->Name = "FrameSkip";
        // 
        // FrameInterval
        // 
        this->FrameInterval->HeaderText = "Interval";
        this->FrameInterval->Name = "FrameInterval";
        // 
        // FrameEffectStart
        // 
        this->FrameEffectStart->HeaderText = "EffectStart";
        this->FrameEffectStart->Name = "FrameEffectStart";
        // 
        // FrameEffectCount
        // 
        this->FrameEffectCount->HeaderText = "EffectCount";
        this->FrameEffectCount->Name = "FrameEffectCount";
        // 
        // FrameEffectSkip
        // 
        this->FrameEffectSkip->HeaderText = "EffectSkip";
        this->FrameEffectSkip->Name = "FrameEffectSkip";
        // 
        // FrameEffectInterval
        // 
        this->FrameEffectInterval->HeaderText = "EffectInterval";
        this->FrameEffectInterval->Name = "FrameEffectInterval";
        // 
        // FrameReverse
        // 
        this->FrameReverse->HeaderText = "Reverse";
        this->FrameReverse->Name = "FrameReverse";
        // 
        // FrameBlend
        // 
        this->FrameBlend->HeaderText = "Blend";
        this->FrameBlend->Name = "FrameBlend";
        // 
        // OpenLibraryDialog
        // 
        this->OpenLibraryDialog->Filter = "Library|*.Lib";
        // 
        // SaveLibraryDialog
        // 
        this->SaveLibraryDialog->Filter = "Library|*.Lib";
        // 
        // ImportImageDialog
        // 
        this->ImportImageDialog->Filter = "Images (*.BMP;*.JPG;*.GIF;*.PNG)|*.BMP;*.JPG;*.GIF;*.PNG|All files (*.*)|*.*";
        this->ImportImageDialog->Multiselect = true;
        // 
        // OpenWeMadeDialog
        // 
        this->OpenWeMadeDialog->Filter = "WeMade|*.Wil;*.Wtl|Shanda|*.Wzl;*.Miz|Lib|*.Lib";
        this->OpenWeMadeDialog->Multiselect = true;
        // 
        // statusStrip
        // 
        this->statusStrip->Items->AddRange(std::vector<System::Windows::Forms::ToolStripItem*> {this->toolStripStatusLabel, this->toolStripProgressBar});
        this->statusStrip->LayoutStyle = System::Windows::Forms::ToolStripLayoutStyle::HorizontalStackWithOverflow;
        this->statusStrip->Location = new System::Drawing::Point(0, 708);
        this->statusStrip->Name = "statusStrip";
        this->statusStrip->Size = new System::Drawing::Size(1036, 22);
        this->statusStrip->TabIndex = 2;
        this->statusStrip->Text = "statusStrip";
        // 
        // toolStripStatusLabel
        // 
        this->toolStripStatusLabel->Name = "toolStripStatusLabel";
        this->toolStripStatusLabel->Size = new System::Drawing::Size(90, 17);
        this->toolStripStatusLabel->Text = "Selected Image:";
        // 
        // toolStripProgressBar
        // 
        this->toolStripProgressBar->Alignment = System::Windows::Forms::ToolStripItemAlignment::Right;
        this->toolStripProgressBar->Name = "toolStripProgressBar";
        this->toolStripProgressBar->Size = new System::Drawing::Size(200, 16);
        this->toolStripProgressBar->Step = 1;
        this->toolStripProgressBar->Style = System::Windows::Forms::ProgressBarStyle::Continuous;
        // 
        // FolderLibraryDialog
        // 
        this->FolderLibraryDialog->ShowNewFolderButton = false;
        // 
        // FrameAnimTimer
        // 
        this->FrameAnimTimer->Tick += new System::EventHandler(this->FrameAnimTimer_Tick);
        // 
        // LMain
        // 
        this->AutoScaleDimensions = new System::Drawing::SizeF(6.0F, 13.0F);
        this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
        this->ClientSize = new System::Drawing::Size(1036, 730);
        this->Controls->Add(this->splitContainer1);
        this->Controls->Add(this->statusStrip);
        this->Controls->Add(this->MainMenu);
        this->DoubleBuffered = true;
        this->Icon = (std::any_cast<System::Drawing::Icon*>(resources->GetObject("$this.Icon")));
        this->MainMenuStrip = this->MainMenu;
        this->MinimumSize = new System::Drawing::Size(650, 450);
        this->Name = "LMain";
        this->StartPosition = System::Windows::Forms::FormStartPosition::CenterScreen;
        this->Text = "Legend of Mir Library Editor";
        this->Resize += new System::EventHandler(this->LMain_Resize);
        this->MainMenu->ResumeLayout(false);
        this->MainMenu->PerformLayout();
        this->splitContainer1->Panel1.ResumeLayout(false);
        this->splitContainer1->Panel2.ResumeLayout(false);
        (static_cast<System::ComponentModel::ISupportInitialize*>(this->splitContainer1))->EndInit();
        this->splitContainer1->ResumeLayout(false);
        this->splitContainer2->Panel1.ResumeLayout(false);
        this->splitContainer2->Panel1.PerformLayout();
        this->splitContainer2->Panel2.ResumeLayout(false);
        (static_cast<System::ComponentModel::ISupportInitialize*>(this->splitContainer2))->EndInit();
        this->splitContainer2->ResumeLayout(false);
        (static_cast<System::ComponentModel::ISupportInitialize*>(this->nudJump))->EndInit();
        (static_cast<System::ComponentModel::ISupportInitialize*>(this->pictureBox))->EndInit();
        (static_cast<System::ComponentModel::ISupportInitialize*>(this->ZoomTrackBar))->EndInit();
        this->panel->ResumeLayout(false);
        this->panel->PerformLayout();
        (static_cast<System::ComponentModel::ISupportInitialize*>(this->ImageBox))->EndInit();
        this->tabControl->ResumeLayout(false);
        this->tabImages->ResumeLayout(false);
        this->tabFrames->ResumeLayout(false);
        (static_cast<System::ComponentModel::ISupportInitialize*>(this->frameGridView))->EndInit();
        this->statusStrip->ResumeLayout(false);
        this->statusStrip->PerformLayout();
        this->ResumeLayout(false);
        this->PerformLayout();

        delete resources;
    }
}
